**************************************** 
*** Replication Package - Supplement ***
****************************************

version 18
clear all
set scheme burd
run "analysis_programs.do"

*****************************************************************
*** Table C1. Vignette experiment: Sample: Inclusion criteria ***
*****************************************************************

** Write manually to table.

************************************ 
*** Figure C1. Driving knowledge ***
************************************ 

use "vignette_experiment.dta" , clear
global sample idtag & inrange(pair,11,19) & !everinattentive 

summ selfseg if $sample , d
di r(p50)  // selfseghigh if selfseg >= r(p50) = 7

histogram selfseg if $sample , discrete freq addlabels ///
  addplot( scatteri 0 6.5 250 6.5 , ///
     recast(line) lc(red) lw(medthick) ) ///
  xsc(r(1 9)) xla(1(2)9) legend(off)    
graph export "FigureC1.png" , replace as(png)  


***********************************************************
*** Table C2. Effect of real time traffic info on choice ** 
*********************************************************** 

use "vignette_experiment.dta" , clear

global sample inrange(pair,21,29) & !everinattentive 
global outregopt landscape plain coljust(lc) varlabels ///
  stats(b se p) nostar // starloc(1) starlevels(10 5 1)
global expvar ib0.tech c.comm 1.commabovecurrent ///
  0.opt 1.displayedsecond   
  
outreg, clear(regskill) 
cmrologit pref $expvar if $sample & selfseghigh == 0 , cl(id)
domarginswithcurrentcomm if opt!=0 & e(sample) , ///
  dydx(1.tech) expression( exp(xb()) / ( 1 + exp(xb()) ) * 100 )
svyregstat 

cmrologit pref $expvar if $sample & selfseghigh == 1 , cl(id)
domarginswithcurrentcomm if opt!=0 & e(sample) , ///
  dydx(1.tech) expression( exp(xb()) / ( 1 + exp(xb()) ) * 100 )
svyregstat 

file open regs2 using "reg_skill2_rti_all.txt" , ///
   write replace   // compile data for Figure 2 (next bookmark)
file write regs2 "selfseghigh" _tab "cwd" _tab "ls" ///
   _tab "lc" _tab "uc" _newline
   
cmrologit pref $expvar ib0.selfseghigh#1.tech ///
  ib0.selfseghigh#c.comm if $sample , cl(id)
domarginswithcurrentcomm if opt!=0 & e(sample) , ///
  dydx(1.tech) expression( exp(xb()) / ( 1 + exp(xb()) ) * 100 ) ///
  at1(selfseghigh == 0) at2(selfseghigh == 1) statname(ls) fmt(%9.1f)
svyregstatskill "regs2" "selfseghigh" ///
  "(c) All subjects" "regskill"

  local matrix A0 = r(table)
  matrix list A0
  local ls0 : display %5.2f A0[1,3] 
  local ls0p : display %5.2f A0[4,3] 
  local ls0lc : display %5.2f A0[5,3]
  local ls0uc : display %5.2f A0[6,3]
  local ls1 : display %5.2f A0[1,4] 
  local ls1p : display %5.2f A0[4,4] 
  local ls1lc : display %5.2f A0[5,4]
  local ls1uc : display %5.2f A0[6,4]
  file write regs2 "0" _tab "" _tab (`ls0') _tab (`ls0lc') ///
    _tab (`ls0uc') _newline 
  file write regs2 "1" _tab "" _tab (`ls1') _tab (`ls1lc') ///
    _tab (`ls1uc') _newline 
	
 nlcom cwd0 : -_b[1.tech] / _b[c.comm]
  matrix A0 = r(table)
  local cwd0 : display %5.2f A0[1,1] 
  local cwd0p : display %5.2f A0[4,1] 
  local cwd0lc : display %5.2f A0[5,1]
  local cwd0uc : display %5.2f A0[6,1]
  file write regs2 "0" _tab (`cwd0') _tab "" _tab (`cwd0lc') ///
    _tab (`cwd0uc') _newline  
	
 nlcom cwd1 : - ( _b[1.tech] + _b[1.selfseghigh#1.tech] ) / ///
   ( _b[c.comm] + _b[1.selfseghigh#c.comm] )
  matrix A1 = r(table)
  local cwd1 : display %5.2f A1[1,1] 
  local cwd1p : display %5.2f A1[4,1] 
  local cwd1lc : display %5.2f A1[5,1]
  local cwd1uc : display %5.2f A1[6,1]
  file write regs2 "1" _tab (`cwd1') _tab "" _tab (`cwd1lc') ///
   _tab (`cwd1uc') _newline 
  file close regs2
  
  local subj : display %6.0f  e(N_clust)
  local ll : display %9.1f e(ll) 
  
outreg , $outregopt ///
  ctitle("VARIABLES" , "Contingent: driving knowledge") ///
  addrows( "Subjects", "`subj'" \ "LogL", "`ll'" \ ///
   "CWD low skill", "`cwd0'" \ "", "[`cwd0p']" \ ///
   "CWD high skill", "`cwd1'" \ "", "[`cwd1p']" \ ///
   "Work low skill", "`ls0'" \ "", "[`ls0p']" \ ///
   "Work high skill", "`ls1'" \ "", "[`ls1p']" ) ///
  merge(regskill)  

outreg using "TableC2.doc", ///
  $outregopt replay(regskill) ///
  note("Estimated by Stata routine, cmrologit; Dependent variable: Choice; ") ///
  replace


*******************************************
*** Table C3. Map app: Robustness tests ***
*******************************************

use "vignette_experiment.dta" , clear
global sample inrange (pair,11,19) & !everinattentive 

global sample inrange(pair,11,19) & !everinattentive 
global outregopt landscape plain coljust(lc) varlabels ///
  stats(b se p) nostar // starloc(1) starlevels(10 5 1)
global expvar ib0.tech c.comm 1.commabovecurrent ///
  0.opt 1.displayedsecond   
  
summ selfseg , detail
gen selfseghighalt = ( selfseg > r(p50) )

outreg, clear(regskill) 
// Define low skill by <= median   
cmrologit pref $expvar ib0.selfseghighalt#1.tech ///
   ib0.selfseghighalt#c.comm if $sample , cl(id)
domarginswithcurrentcomm if opt!=0 & e(sample) , dydx(1.tech) ///
  expression( exp(xb()) / ( 1 + exp(xb()) ) * 100 ) ///
  at1(selfseghighalt == 0) at2(selfseghighalt == 1) ///
  statname(ls) fmt(%9.1f)
svyregstatskill "work_skill" "selfseghighalt" ///
  "() Low skill: Incl median" "regskill" 
 
// Measure skill by location test  
cmrologit pref $expvar ib0.test1high#1.tech ///
   ib0.test1high#c.comm if $sample , cl(id)
domarginswithcurrentcomm if opt!=0 & e(sample) , dydx(1.tech) ///
  expression( exp(xb()) / ( 1 + exp(xb()) ) * 100 ) ///
  at1(test1high == 0) at2(test1high == 1) statname(ls) fmt(%9.1f)
svyregstatskill "work_skill.txt" "test1high" ///
  "() Measure skill by location test" "regskill" 
  
// Exclude outliers
preserve
 winsor2 ridesperhour incomelesscomm earnings, cuts(5,95) trim 
 drop if mi(ridesperhour) | mi(incomelesscomm) | mi(earnings)
    
 cmrologit pref $expvar ib0.selfseghigh#1.tech ///
   ib0.selfseghigh#c.comm if $sample , cl(id)
 domarginswithcurrentcomm if opt!=0 & e(sample) , dydx(1.tech) ///
  expression( exp(xb()) / ( 1 + exp(xb()) ) * 100 ) ///
  at1(selfseghigh == 0) at2(selfseghigh == 1) statname(ls) fmt(%9.1f)
 svyregstatskill "work_skill.txt" "selfseghigh" ///
  "() Exclude outliers" "regskill" 
restore
  
// Incidental paramters bias: Next Section 

// Cluster by referral group
cmrologit pref $expvar ib0.selfseghigh#1.tech ///
   ib0.selfseghigh#c.comm if $sample , vce(cl referralid)  
domarginswithcurrentcomm if opt!=0 & e(sample) , dydx(1.tech) ///
  expression( exp(xb()) / ( 1 + exp(xb()) ) * 100 ) ///
  at1(selfseghigh == 0) at2(selfseghigh == 1) ///
  statname(ls) fmt(%9.1f)
svyregstatskill "work_skill.txt" "selfseghigh" ///
  "() Cluster s.e. by referral group" "regskill" 
    
outreg using "TableC3.doc", ///
  $outregopt replay(regskill) ///
  note("Estimated by Stata routine, cmrologit; Dependent variable: Choice; ") ///
  replace

**************************************************
*** Table C3. Column (d) Incidental parameters *** 
**************************************************

use "incdpar_bootstrap_result.dta" , clear

gen p = 2*(normal(-(bcval/se)))
drop mlval
foreach x in 1.commabovecurrent 0.opt 1.displayedsecond {
  drop if Parameter == "`x'"  	
}
gen i = _n
labmask i , values(Parameter)
drop Parameter

order bcval se p ci_l ci_u 
format bcval se p ci_l ci_u %04.3f
local i = 1
foreach x in bcval se p ci_l ci_u {
  rename `x' var`i'
  local i = `i' + 1
}
reshape long var , i(i) j(parameter)
 
label define parlabel 1 "Coefficient" 2 "se" 3 "p" 4 "ci_l" 5 "ci_u"
label values parameter parlabel
// copy manually to table.

  
************************************************* 
*** Figure C2. Mechanism: Amenity/productivity **
************************************************* 

use "vignette_experiment.dta" , clear
global sample inrange(pair,11,19) & !everinattentive 

ksmirnov amenity if $sample & idtag , by(selfseghigh)

preserve
keep if $sample & idtag  // one answer per subject 

replace amenity = amenity - 0.25 if selfseghigh == 0
replace amenity = amenity + 0.25 if selfseghigh == 1

global graphopt discrete percent fintensity(50) barwidth(0.5) 
twoway (histogram amenity if selfseghigh == 0 , ///
    $graphopt color("33 102 172") ) ///
  (histogram amenity if selfseghigh == 1 , ///
    $graphopt color("178 24 43") ) , ///
  xlabel( 0 "0 = lowest" 4 "4 = highest" , ///
    noticks labsize(large)) ///
  xtitle( "Amenity" , size(large) ) ///
  ylabel( , labsize(large)) ///
  ytitle( "Responses (percent)" , size(large) ) ///
  legend( pos(6) row(2) size(large) ///
    order(1 "Low driving knowledge" 2 "High driving knowledge") )
graph export "FigureC2.png" , ///
  replace as(png)     
restore
   
***************************************************
*** Table F1. Field experiment: Work: Robustness **
***************************************************

use "field_experiment.dta" , clear
qui hrv 3_20_0 4_20_20

global sample hypo == 0 // All destinations: N = 150 
global explvar i.tech i.selfseghigh 1.tech#1.selfseghigh
global keepvar 1.tech 1.selfseghigh 1.tech#1.selfseghigh
global fe i.group i.destination 
global regopt vce(cluster id) 
global outregopt landscape plain coljust(lc) varlabels ///
  stats(b se p) nostar

outreg, clear(regwork) 
reg work $explvar riskaverse intrinsic if $sample , $regopt
fieldregstatskillfe "work" "work_skill_robust.txt" ///
  "$keepvar riskaverse intrinsic" ///
  "(a) Control for personal characteristics" "No" "No" "No" "regwork"
  // Not registered  
  
reg work $explvar if $sample ,  vce(cluster group) 
fieldregstatskillfe "work" "work_skill_robust.txt" "$keepvar" ///
  "(b) Cluster s.e. by group" "No" "No" "No" "regwork" 
  // Not registered    
  
reg work $explvar fare if $sample , $regopt
fieldregstatskillfe "work" "work_skill_robust.txt" "$keepvar fare" ///
  "(c) Control for fare" "No" "No" "No" "regwork" 
  // Not registered: to prepare for Heckman selection model
  
reghdfe work tech if $sample , absorb(group destination) $regopt 
fieldregstatfe "work" "tech" ///
  "(d) Fixed effects: group and destination" ///
  "Yes" "Yes" "No" "regwork"  // Registration: Spec B (OLS)

reghdfe work $explvar if $sample , ///
  absorb(group destination destination#selfseghigh) $regopt  
fieldregstatskillfe "work" "work_skill_robust.txt" ///
  "1.tech 1.tech#1.selfseghigh" ///
  "(e) Fixed effects: Contingent on skill" "Yes" "Yes" "Yes" "regwork"
  // Registration: Spec B' (OLS); 1.selfseghigh absorbed by group f.e.
  
outreg using "TableF1-reg.doc" , ///
  landscape plain coljust(lc) varlabels replay(regwork) ///
  note("Estimated by OLS (Stata routines, reg and reghdfe);" ///
   "Dependent variable: Accept work; Robust standard errors clustered by subject in parentheses; p-values in brackets ") ///
  replace  

** Logit **

outreg, clear(regwork) 

logit work tech if $sample , $regopt 
fieldregstatfe "work" "tech" ///
  "(a) Basic specification" ///
  "No" "No" "No" "regwork"  // Registration: Spec A (logit)  
  
logit work $explvar if $sample , $regopt
fieldregstatskillfe "work" "work_skill_robust.txt" "$keepvar" ///
  "(b) Contingent skill" "No" "No" "No" "regwork"  
  // Registration: Spec A' (logit)
  
logit work $explvar ///
  if $sample & inlist(difficulty, 1, 2) , vce(cluster id)
fieldregstatskillfe "work" "work_skill_robust.txt" "$keepvar" ///
  "(c) Easy/intermediate destinations" "No" "No" "No" "regwork"  
  
logit work tech $fe if $sample , $regopt 
fieldregstatfe "work" "tech" ///
  "(d) Fixed effects: group and destination" ///
  "Yes" "Yes" "No" "regwork"  // Registration: Spec B (logit)

logit work ///
  $fe destination#selfseghigh $explvar if $sample , $regopt 
fieldregstatskillfe "work" "work_skill_logit.txt" "1.tech 1.tech#1.selfseghigh" ///
  "(e) Contingent on skill:" "Yes" "Yes" "Yes" "regwork"
  // Registration: Spec B' (logit)

outreg using "TableF1-logit.doc" , ///
  landscape plain coljust(lc) varlabel replay(regwork) ///
  note("Estimated by Stata routine ;" ///
   "Dependent variable: Accept work; Robust standard errors clustered by subject in parentheses; p-values in brackets ") ///
  replace  

** Add the below marginal effects manually 

preserve
  
logit work ///
  $fe destination#selfseghigh $explvar if $sample , $regopt 
keep if e(sample)
replace selfseghigh = 0
replace tech = 0
predict p00 , pr
replace selfseghigh = 1
replace tech = 0
predict p10 , pr
replace selfseghigh = 0
replace tech = 1
predict p01 , pr
replace selfseghigh = 1
replace tech = 1
predict p11 , pr

gen dydx0 = p01 - p00
gen dydx1 = p11 - p10

summ dydx0
summ dydx1
/*
    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
       dydx0 |        105     .478394    .1248957   .2913544   .6118815
       dydx1 |         85    .6096208    .1554925   .3087127   .7649571
*/ 
 
restore 

************************************************************* 
*** Table F2 . Field experiment: Tech on stress ** 
************************************************************* 

outreg, clear(regmech)

qreg rmssd_delta2 tech , vce(robust)
fieldmedianstat "rmssd_delta2" "tech" "RMSSD change" "regmech"
 // p = 0.45
  
qreg stai tech , vce(robust)
fieldmedianstat "stai" "tech" "STAI" "regmech"

outreg using "TableF2.doc" , ///
  $outregopt replay(regmech) ///
  note("Estimated by ;" ///
   "Standard errors in parentheses; p-values in brackets ") ///
  replace


************************************************************** 
*** Table F3. Field experiment: RMSSD--registered analyses ***
**************************************************************

global depvar rmssd_delta2

outreg, clear(regrmssd)
reg $depvar tech if $sample, $regopt 
fieldregstatfe "$depvar" "tech" "(a) Basic" "No" "No" "No" "regrmssd"

reghdfe $depvar tech if $sample, absorb(group) $regopt 
fieldregstatfe "$depvar" "tech" "(b) Group fixed effects" "Yes" "No" "No" "regrmssd"

reg $depvar tech riskaverse intrinsic if $sample, $regopt 
fieldregstatfe "$depvar" "tech riskaverse intrinsic" "(c) Personal characteristics" "No" "No" "No" "regrmssd"

reghdfe $depvar tech riskaverse intrinsic if $sample, absorb(group) $regopt 
fieldregstatfe "$depvar" "tech riskaverse intrinsic" "(d) Group fixed effects and personal characteristics" "Yes" "No" "No" "regrmssd"

reg $depvar i.tech i.selfseghigh 1.tech#1.selfseghigh if $sample, $regopt 
fieldregstatskillfe "$depvar" "stress_rmssd.txt" "1.tech 1.selfseghigh 1.tech#1.selfseghigh" "(e) Contingent skill" "No" "No" "No" "regrmssd"

reghdfe $depvar i.tech i.selfseghigh 1.tech#1.selfseghigh rmssd3 if $sample, absorb(group) $regopt 
fieldregstatskillfe "$depvar" "stress_rmssd.txt" "1.tech 1.tech#1.selfseghigh" "(f) Contingent skill: Group fixed effects" "Yes" "No" "No" "regrmssd"

reg $depvar i.tech i.selfseghigh 1.tech#1.selfseghigh rmssd3 riskaverse intrinsic if $sample, $regopt 
fieldregstatskillfe "$depvar" "stress_rmssd.txt" "1.tech 1.selfseghigh 1.tech#1.selfseghigh riskaverse intrinsic" "(g) Contingent skill: Personal characteristics" "No" "No" "No" "regrmssd"

reghdfe $depvar i.tech i.selfseghigh 1.tech#1.selfseghigh rmssd3 riskaverse intrinsic if $sample, absorb(group) $regopt 
fieldregstatskillfe "$depvar" "stress_rmssd.txt" "1.tech 1.tech#1.selfseghigh riskaverse intrinsic" "(h) Contingent skill: Group fixed effects and personal characteristics" "Yes" "No" "No" "regrmssd"

outreg using "TableF3.doc" , ///
  $outregopt replay(regrmssd) ///
  note("Estimated by reghdfe;" ///
   "Robust standard errors clustered by subject in parentheses; p-values in brackets ") ///
  replace

  
*************************************************************
*** Table F4. Field experiment: STAI--registered analyses ***
*************************************************************

replace stai = stai - 5
outreg, clear(regstai)
poisson stai tech , vce(cluster id)
fieldregstatfe "stai" "tech" "(a) Basic" "No" "No" "No" "regstai"

ppmlhdfe stai tech , $regopt d
fieldregstatfe "stai" "tech" "(b) Group fixed effects" ///
  "Yes" "No" "No" "regstai"

poisson stai tech riskaverse intrinsic , ///
  vce(cluster id)
fieldregstatfe "stai" "tech riskaverse intrinsic" ///
 "(c) Personal characteristics" "No" "No" "No" "regstai"

ppmlhdfe stai tech riskaverse intrinsic , $regopt d
fieldregstatfe "stai" "tech riskaverse intrinsic" ///
 "(d) Group fixed effects and personal characteristics" ///
 "Yes" "No" "No"  "regstai"

poisson stai i.tech i.selfseghigh 1.tech#1.selfseghigh , vce(cluster id)
fieldregstatskillfe "stai" "mech_skill.txt" ///
  "1.tech 1.selfseghigh 1.tech#1.selfseghigh" "(e) Contingent skill" ///
  "No" "No" "No" "regstai"
 
ppmlhdfe stai i.tech i.selfseghigh 1.tech#1.selfseghigh , $regopt d
fieldregstatskillfe "stai" "mech_skill.txt" ///
  "1.tech 1.tech#1.selfseghigh" ///
  "(f) Contingent skill: Group fixed effects" "Yes" "No" "No" "regstai"

poisson stai i.tech i.selfseghigh 1.tech#1.selfseghigh riskaverse intrinsic ///
  riskaverse_skill intrinsic_skill , vce(cluster id)
fieldregstatskillfe "stai" "mech_skill.txt" ///
  "1.tech 1.selfseghigh 1.tech#1.selfseghigh riskaverse intrinsic" ///
  "(g) Contingent skill: Personal characteristics" "No" "No" "No" "regstai"

ppmlhdfe stai i.tech i.selfseghigh 1.tech#1.selfseghigh riskaverse ///
  intrinsic riskaverse_skill intrinsic_skill , $regopt d
fieldregstatskillfe "stai" "mech_skill.txt" ///
  "1.tech 1.tech#1.selfseghigh riskaverse intrinsic" ///
  "(h) Contingent skill: Group fixed effects and personal characteristics" "Yes" "No" "No" "regstai"

outreg using "TableF4.doc" , ///
  $outregopt replay(regstai) ///
  note("Estimated by poisson regression;" ///
  "Robust standard errors clustered by subject in parentheses; p-values in brackets ") ///
  replace 


  
********************************************************
*** Figure G1.G2. Amenity of Self-driving technology ***
********************************************************

use "vignette_experiment.dta" , clear
global sample !everinattentive

assert tech == 1 & comm == currentcomm+2 if pair==52 & opt==1
assert tech == 0 & comm == currentcomm+3 if pair==52 & opt==2
gen byte autovehchosetech = choicebtwvignettes if pair==52 & opt==1
label var autovehchosetech "Chose self-driving"
gen byte treated = pairgp=="treatment" if pair==52 & opt==1
label var treated "Information treatment"

label var selfseghigh "High driving knowledge (above median)"
sum timetaken if $sample & !mi(treated), d
gen responselong = timetaken >= r(p50) if !mi(treated)
label var responselong "Long response time (above median)"

** Figure G1. Amenity by low/high selfknowledge **
preserve
keep if $sample & !mi(treated)
collapse (mean) mean = autovehchosetech (sd) sd = autovehchosetech ///
  (count) n = autovehchosetech , by(treated)

generate uc = mean + invttail(n-1,0.025)*(sd / sqrt(n))
generate lc = mean - invttail(n-1,0.025)*(sd / sqrt(n))
format mean lc uc  %4.2f

keep mean lc uc treated
generate selftreat = treated    // prepare for append with 

drop if mi(treated)
duplicates drop treated , force

tempfile autoveh_treat
save `autoveh_treat', replace
restore

preserve
keep if $sample & !mi(treated)
collapse (mean) mean = autovehchosetech (sd) sd = autovehchosetech ///
  (count) n = autovehchosetech , by(selfseghigh treated)

generate uc = mean + invttail(n-1,0.025)*(sd / sqrt(n))
generate lc = mean - invttail(n-1,0.025)*(sd / sqrt(n))
format mean lc uc  %4.2f

generate selftreat = treated + 3  if selfseghigh == 0
replace selftreat = treated + 6  if selfseghigh == 1

append using `autoveh_treat'
drop if mi(selftreat)

global graphopt1 fintensity(50) lcolor("33 102 172") fcolor("33 102 172")
global graphopt2 fintensity(50) lcolor("178 24 43") fcolor("178 24 43")
twoway ( bar mean selftreat if treated == 0 & inlist(selftreat,0,1) , ///
     $graphopt1 ) ///
  (bar mean selftreat if treated == 1 & inlist(selftreat,0,1) , ///
     $graphopt2 ) ///
  (bar mean selftreat if treated == 0 & !inlist(selftreat,0,1) , ///
     $graphopt1 ) ///
  (bar mean selftreat if treated == 1 & !inlist(selftreat,0,1) , ///
     $graphopt2 ) ///
  (rcap lc uc selftreat, $rcapopt ), ///
  xlabel(0.5 "{bf:All}" 3.5 "Low" 6.5 "High", noticks) ///
  xtitle("Driving knowledge") ///
  ytitle("Chose self-driving") ///
  legend(pos(6) row(1) order(1 "Control" 2 "Treated")) ///
  xline( 2, lcolor(red) lpattern(solid) lwidth(medthick) ) ///
  scheme(burd)
graph export "FigureG1.png" , replace as(png)     
restore
  
** Figure G2. Amenity by driver response speed **
preserve
keep if $sample & !mi(treated)
collapse (mean) mean = autovehchosetech (sd) sd = autovehchosetech ///
  (count) n = autovehchosetech , by(responselong treated)

generate uc = mean + invttail(n-1,0.025)*(sd / sqrt(n))
generate lc = mean - invttail(n-1,0.025)*(sd / sqrt(n))
format mean lc uc  %4.2f

generate selftreat = treated + 3  if responselong == 0
replace selftreat = treated + 6  if responselong == 1

drop if mi(selftreat)

twoway (bar mean selftreat if treated == 0, fintensity(50) lcolor("33 102 172") fcolor("33 102 172")) ///
  (bar mean selftreat if treated == 1, fintensity(50) lcolor("178 24 43") fcolor("178 24 43")) ///
  (rcap lc uc selftreat, $rcapopt ), ///
  xlabel(3.5 "Below median" 6.5 "Above median", noticks) ///
  xtitle("Response time") ///
  ytitle("Chose self-driving") ///
  legend(pos(6) row(1) order(1 "Control" 2 "Treated")) ///
  scheme(burd)

graph export "FigureG2.png" , replace as(png)     
restore

***********************************************
****** Erase Intermediate File generated ******
***********************************************
erase "work_skill_robust.txt"
erase "work_skill_logit.txt"
erase "stress_rmssd.txt"
erase "reg_skill2_rti_all.txt"
erase "mech_skill.txt"
